package com.xiangban.yanglaodajie_platform.controller;

import com.xiangban.yanglaodajie_platform.aop.Permission;
import com.xiangban.yanglaodajie_platform.entity.Takes;
import com.xiangban.yanglaodajie_platform.entity.res.ApiResult;
import com.xiangban.yanglaodajie_platform.service.TakesService;
import com.xiangban.yanglaodajie_platform.utils.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/4/16 15:01
 */

@RestController
@RequestMapping("/api/pri/takes")
@Api(tags = "自取信息")
public class TakesController {
    @Autowired
    private TakesService takesService;

    @PostMapping("/getUserInfo")
    @ApiOperation("获取用户自取信息")
    @Permission
    public JsonData getUserInfo(@RequestBody Takes takes){
       return JsonData.buildSuccess(takesService.getUserInfo(takes),"自取信息");
    }
    @PostMapping("/updateUserInfo")
    @ApiOperation("修改用户自取信息")
    @Permission
    public JsonData updateUserInfo(@RequestBody Takes takes) throws ParseException {
        takesService.updateUserInfo(takes);
        return JsonData.buildSuccess();
    }
}
